import $http from '../../../servers/http';
import { Result } from '../../schema/Result';
/* 通知流程管理
---------------------------------------------------------------- */
import {
  CreateNotifyFlowRequest,
  EditNotifyFlowRequest,
  NotifyFlowInfo,
} from '../../schema/NotifyFlows';
/**
 * 查询在线的通知流程
 * @param data
 */
export const getOnlineNotifyFlow = (data: {
  pageSize?: number;
  pageNo?: number;
  flowName?: string;
}): Promise<Result<NotifyFlowInfo[]>> => {
  return $http.get({
    url: '/robotmanage/notifyflows/online',
    data,
  });
};
/**查询通知流程列表 */
export const getNotifyFlowList = (data: {
  pageSize: number;
  pageNo: number;
  flowName?: string;
}): Promise<Result<NotifyFlowInfo[]>> => {
  return $http.get({
    url: '/robotmanage/notifyflows',
    data,
  });
};
/**新增通知流程 */
export const createNotifyFlow = (data: CreateNotifyFlowRequest): Promise<Result<null>> => {
  return $http.post({
    url: '/robotmanage/notifyflows',
    data,
  });
};

/**查询通知流程详情 */
export const queryNotifyFlowById = (id: number): Promise<Result<NotifyFlowInfo>> => {
  return $http.get({
    url: `/robotmanage/notifyflows/${id}`,
  });
};

/**修改通知流程 */
export const editNotifyFlow = (id: number, data: EditNotifyFlowRequest): Promise<Result<null>> => {
  return $http.put({
    url: `/robotmanage/notifyflows/${id}`,
    data,
  });
};
/**删除通知流程 */
export const deleteNotifyFlow = (id: number): Promise<Result<null>> => {
  return $http.delete({
    url: `/robotmanage/notifyflows/${id}`,
  });
};
/**上线通知流程 */
export const onlineNotifyFlow = (id: number): Promise<Result<null>> => {
  return $http.patch({
    url: `/robotmanage/notifyflows/${id}/status/on`,
  });
};
/**下线通知流程 */
export const offNotifyFlow = (id: number): Promise<Result<null>> => {
  return $http.patch({
    url: `/robotmanage/notifyflows/${id}/status/off`,
  });
};
